<template>
    <div class="forum-comment">
        <el-dialog title="" :visible.sync="show" width="10rem">
            <h3>评论管理</h3>
            <div class="m-btns">
                <div class="m-btn-item" @click="delFun">删除</div>
                <div class="m-btn-item" @click="bestFun">设置为最佳评论</div>
                <div class="m-btn-item" @click="comment">评论</div>
            </div>
        </el-dialog>

    </div>
</template>

<script>
import { delComment, setBestComment } from "@/api/forum";


export default {
    components: {

    },
    data() {
        return {
            show: false,
            item: {}
        }
    },
    mounted() {

    },
    methods: {
        open(item) {
            this.item = item
            this.show = true
        },
        delFun() {
            this.$confirm('确认删除此评论吗?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                delComment({ id: this.item.id }).then(res => {
                    this.$message.success('删除成功')
                    this.show = false
                    this.$emit('refresh')
                })
            }).catch(() => {})
        },
        bestFun() {
            this.$confirm('确认将此评论设置为最佳评论吗?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                setBestComment({ id: this.item.id }).then(res => {
                    this.$message.success('设置成功')
                    this.show = false
                    this.$emit('refresh')
                })
            }).catch(() => {})
        },
        comment(){
            this.show = false
            this.$emit('comment',this.$route.params.id,this.item.id,this.item)
        }

    }
}
</script>

<style lang="less">
.ql-toolbar.ql-snow,
.ql-container.ql-snow {
    border: 1px solid #DCDFE6;
}
</style>

<style lang="less" scoped>
.forum-comment {
    /deep/.el-dialog {
        border-radius: 0.1rem;
    }

    /deep/.el-dialog__body {
        padding: 0.875rem 0.625rem;
        ;
    }

    /deep/.el-dialog__header {
        display: none;
    }

    h3 {
        font-size: 0.3125rem;
        color: #333;
        font-weight: 600;
        margin: 0 0 0.375rem 0;
    }

    p {
        margin: 0 0 0.375rem 0;
        font-size: 0.2rem;
        color: #9695A3;
    }

    .m-btns {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;

        .m-btn-item {
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
            width: 4rem;
            height: 0.5rem;
            background: #FFFFFF;
            border-radius: 0.1rem;
            border: 0.0125rem solid #D2D6DB;
            font-size: 0.175rem;
            color: #000;
            margin-bottom: 0.3rem;
        }
    }

}
</style>